package esb.chapter2.jbi;

import javax.jbi.JBIException;
import javax.jbi.component.Bootstrap;
import javax.jbi.component.InstallationContext;
import javax.management.ObjectName;

import org.apache.log4j.Logger;

/**
 * Simple bootstrap class. The methods in this class are called when
 * the component is installed/uninstalled to the JBI container.
 * 
 * @author nl24167
 */
public class HelloJBIBootstrap implements Bootstrap {
	
	private static Logger LOG = Logger.getLogger(HelloJBIBootstrap.class);
	private InstallationContext installationContext;

	/**
	 * Cleans up any resources used during installation of the component.
	 */
	public void cleanUp() throws JBIException {
		LOG.info("In cleanup of bootstrap: " + this.getClass());
	}

	/**
	 * Name of the optional installer mbean.
	 * 
	 * Not used in this example.
	 */
	public ObjectName getExtensionMBeanName() {
		return null;
	}

	/**
	 * Initializes the installationContext of this component.
	 */
	public void init(InstallationContext installationContext) throws JBIException {
		this.installationContext = installationContext;
		LOG.info("Initializing component: " + installationContext.getComponentName());
	}

	public void onInstall() throws JBIException {
		LOG.info("Starting install of component: " + installationContext.getComponentName());
	}

	public void onUninstall() throws JBIException {
		LOG.info("Starting uninstall of component: " + installationContext.getComponentName());
	}

}
